import { useUserStore} from "../store/user";
import constants from "../utils/constants";
const userStore = useUserStore()
const header = {
    'Content-Type': 'application/json',
    'authentication': userStore.getUserToken
  }
export function getAllGroupById(){
    return new Promise((resolve, reject) => {
        wx.request({
            url: constants.database + '/user/category/list',
            methode:'GET',
            header: {
                'Content-Type': 'application/json',
                'authentication': userStore.getUserToken
            },
            success: (res) => {
                resolve(res); // 返回原始 res 对象
            },
            fail: (err) => {
                reject(err);
            }
        });
      });
}

export function getGroupDetail(id){
    return new Promise((resolve, reject) => {
        wx.request({
            url:constants.database + `/user/category/detail/${id}`,
            method:'GET',
            header: header,
            success: (res) => {
                resolve(res); // 返回原始 res 对象
            },
            fail: (err) => {
                reject(err);
            }
        })
      });
}

export function deleteGroup(id,state){
    wx.request({
        url:constants.database + '/user/category/delete',
        method:'PUT',
        data:{
            id:id,
            categoryStatus:state
        },
        header: {
            'Content-Type': 'application/json',
            'authentication': userStore.getUserToken
        }
    })
}